﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Prototipo.Models;
using Prototipo.Filters;
using Prototipo.Helpers;

namespace Prototipo.Controllers
{
    [ComprobarLecturaQR]
    public partial class CartaController : Controller
    {
        private Entidades db = new Entidades();

        //
        // GET: /Carta/

        public virtual ActionResult Index()
        {
            int id_local = this.ID_Local_Session();
            var carta = db.CARTA.Where(c => !c.CAR_ID_NIVEL.HasValue && c.ID_LOCAL == id_local);

            if (!carta.Any())
            {
                return HttpNotFound();
            }

            return View(carta.ToList());
        }

        //
        // GET: /Carta/Details/5

        public virtual ActionResult Details(int id = 0 /*Id del local*/)
        {
            CARTA carta = db.CARTA.Find(id);
            if (carta.ID_LOCAL != this.ID_Local_Session())
            {
                return HttpNotFound();
            }

            if (carta == null)
            {
                return HttpNotFound();
            }

            return View(carta);
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}